home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2001 May / SGI IRIX Base Documentation 2001 May.iso / usr / share / catman / p_man / cat5 / ftn / ftn_mpio.z / ftn_mpio
Encoding:
Text File  |  1998-10-30  |  8.3 KB  |  199 lines

  1.  
  2.  
  3.  
  4. FFFFTTTTNNNN____MMMMPPPPIIIIOOOO((((5555))))                                                        FFFFTTTTNNNN____MMMMPPPPIIIIOOOO((((5555))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      FTN_MPIO - Fortran Multi-Threaded I/O
  10.  
  11. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  12.      The 64-bit Fortran compiler and runtime libraries provide multi-threaded
  13.      I/O functionality for Fortran, in other words, this capability is
  14.      available only to programs compiled with -mips3 or -mips4 option and not
  15.      those compiled with -mips1 or -mips2.  To do Fortran I/O in parallel, the
  16.      threaded subroutine must be compiled with the ----mmmmppppiiiioooo option.   A few
  17.      things need to be noted:
  18.           1) All subroutines in source files compiled with ----mmmmppppiiiioooo option use a
  19.      different I/O interface which allows MP-safe Fortran I/O. However, these
  20.      MP interfaces do take extra runtime check to ensure the integrity of the
  21.      I/O operations and so would effect runtime performance a little (probably
  22.      less than 5%).   For applications which wish to make the most out of
  23.      runtime performance, only those subroutines which get executed in
  24.      parallel or contain parallelized loops with I/O statements in them should
  25.      be compiled with ----mmmmppppiiiioooo option.  The rest could and should be compiled
  26.      without ----mmmmppppiiiioooo option.
  27.           2) The I/O runtime library will ensure that only one thread gets a
  28.      lock on a particular logical unit to avoid several threads stepping on
  29.      each others.   The lock is only released after this thread completes the
  30.      I/O operation.  This implementation means three things: firstly, multiple
  31.      threads can write to multiple files connected to different Fortran
  32.      logical units at the same time; secondly, you cannot have multiple
  33.      threads writing to the same logical unit and expect it to be faster as,
  34.      most likely, it will be significantly slower due to all the lockings,
  35.      queryings, and unlockings on that same logical unit; and, thirdly, when
  36.      you open the same file as different logical units and then having
  37.      multiple threads writing to those logical units to the same file the
  38.      integrity of the file will be compromised.
  39.           3) The I/O runtime routines do not have control over which threads
  40.      get executed and will execute whichever thread that obtains the lock on a
  41.      particular logical unit first.   Therefore, this ability to have multi-
  42.      threaded I/O is most useful in direct access or keyed access I/O where
  43.      each thread performs I/O on a pre-determined record (or where each thread
  44.      performs I/O on a different file) and, therefore, the result is
  45.      independent on the execution order of the threads.  For sequential files,
  46.      since the order of the records written out or read in depends on which
  47.      thread gets executed first, the result could be incorrect unless the
  48.      records are not sequentially related and can be written or read in any
  49.      order.   For example:
  50.  
  51.                 DO 10, I=1,100
  52.                   PRINT *, I
  53.           10    CONTINUE
  54.  
  55.      If this loop is threaded, then the numbers printed out will no longer in
  56.      the sequential order from 1 to 100 and applications depending on the
  57.      numbers being in that strict order will get the wrong result.
  58.           4) Because of the problem with sequential files above, the compiler
  59.      (and/or _p_f_a) will not parallelize loops containing I/O statements
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. FFFFTTTTNNNN____MMMMPPPPIIIIOOOO((((5555))))                                                        FFFFTTTTNNNN____MMMMPPPPIIIIOOOO((((5555))))
  71.  
  72.  
  73.  
  74.      automatically as it would compromise the correctness of the application.
  75.      Loops containing I/O statements must be parallelized manually by adding
  76.      the appropriate directives.  Users who wish to use the ability of pfa,
  77.      for example, to analyze the loop for multi-threading can comment out the
  78.      I/O statements to get the _...._mmmm file with all the parallelization directives
  79.      added to the appropriate loops, and then uncomment the I/O statements and
  80.      compile the _...._mmmm file with the ----mmmmppppiiiioooo option.  That is if they are sure that
  81.      the I/O statements won't be effected by the order in which they are
  82.      executed.  Also because of the performance loss associated with multi-
  83.      threaded Fortran I/O the ----mmmmppppiiiioooo option is never the default regardless of
  84.      other compilation options.  The user must explicitly specify this option
  85.      in case he wants to have I/O statements inside multi-threaded
  86.      loops/subroutines.
  87.           5) The Fortran standard forbids the use of a function call in a list
  88.      of items to be written out in a WRITE/PRINT statement if that function
  89.      itself performs I/O.  This nested I/O usage used to give random result or
  90.      coredump before the multi-threaded I/O implementation and still does now
  91.      if the application is not compiled with ----mmmmppppiiiioooo option.  With the ----mmmmppppiiiioooo
  92.      option, this will give the correct result if the I/O operation inside the
  93.      function is not performed on the same logical unit as the one in the I/O
  94.      statement where the function call is used but will result in a deadlock
  95.      and the process will hang if the nested I/O operations are done on the
  96.      same logical unit.
  97.           6) Internal file I/O is treated as if it were an independent logical
  98.      unit.  That means only one thread can do internal file I/O at a time.
  99.           7) Since the MP I/O runtime library sets its own internal lock on
  100.      the logical unit, it does not effect the normal I/O operation to the
  101.      files and does not impose additional constraint on the operability of the
  102.      I/O statements.  In other words, I/O operations to NFS-mounted files,
  103.      tapes, sockets, etc. do not have any more limitations than those they
  104.      already have, if any.
  105.           8) The ----mmmmppppiiiioooo option effects the runtime library calls generated from
  106.      the I/O statements directly: a different set of MP-safe I/O interfaces
  107.      will be used instead of the default interfaces.  That means this option,
  108.      unlike those compilation options which changes the behavior of the
  109.      runtime I/O library such as ----vvvvmmmmssss____cccccccc by setting a flag inside the Fortran
  110.      main program, is not effected by the fact whether you have the main
  111.      program written in C or Fortran.       9) The default maximum number of
  112.      Fortran logical units that can be opened at the same time is 100,
  113.      including 4 system files.  In single-threaded mode this limit is
  114.      automatically increased if the number of opened exceeds it.  However,
  115.      while I/O operations are being executed in multi-threaded mode, if
  116.      additional files are opened causing the number of opened files to exceed
  117.      this limit, the runtime library will return an error message asking the
  118.      user to set the environment variable FORTRAN_OPENED_UNITS to a bigger
  119.      number and then abort.  In order to run the program to completion, the
  120.      user will need to set FORTRAN_OPENED_UNITS to a number big enough to
  121.      accommodate for all the files being opened at the same time.  To avoid
  122.      this from occurring at all without having to set FORTRAN_OPENED_UNITS,
  123.      all OPEN statements can be done in single-threaded mode before doing
  124.      other I/O operations in parallel.
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. FFFFTTTTNNNN____MMMMPPPPIIIIOOOO((((5555))))                                                        FFFFTTTTNNNN____MMMMPPPPIIIIOOOO((((5555))))
  137.  
  138.  
  139.  
  140. AAAAUUUUTTTTHHHHOOOORRRR
  141.      Calvin Vu
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.